﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentCourses
{
    class Student
    { 
        private const int minFNValue = 10000;
        private const int maxFNValue = 99999;

        private string name;
        private int facultyNumber;
        //private HashSet<Course> courses;

        public Student(string name, int facultyNumber)
        {
            this.FacultyNumber = facultyNumber;
            this.Name = name;
            //courses = new HashSet<Course>();
        }

        public string Name
        {
            get { return name; }
            private set
            {
                if (value == null || value == "")
                {
                    throw new ArgumentNullException("Name can not be null or empty.");
                }
                else
                {
                    name = value;
                }
            }
        }
        
        public int FacultyNumber
        {
            get { return facultyNumber; }
            private set
            {
                if (value >= minFNValue && value <= maxFNValue)
                {
                    facultyNumber = value;
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Faculty number shoud be between 10000 and 99999.");
                }
            }
        }

        public override int GetHashCode()
        {
            return this.FacultyNumber.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            Student other = obj as Student;
            if (this.FacultyNumber == other.FacultyNumber)
            {
                return true;
            }
            return false;
        }
    }
}
